<%
'#################################################################################
'## UnWritten Open Source Blog Engine
'#################################################################################
'## Copyright (C) 2008 Luigi Violin
'##
'## This program is free software: you can redistribute it and/or modify
'## it under the terms of the GNU General Public License as published by
'## the Free Software Foundation, either version 2 of the License, or
'## (at your option) any later version.
'##
'## This program is distributed in the hope that it will be useful,
'## but WITHOUT ANY WARRANTY; without even the implied warranty of
'## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
'## GNU General Public License for more details.
'##
'## You should have received a copy of the GNU General Public License
'## along with this program.  If not, see <http://www.gnu.org/licenses/>.
'##
'## You can obtain support from our forums at:
'##     <http://www.unwrittenblog.com/forums/>
'## Contact the author directly:
'##     <zaamit@hotmail.com/>
'##
'#################################################################################
%>
<!--#include virtual="/version.asp" -->
<%
'admin common functions
function sep1()
  sep1 = "<hr align=""center"" width=""90%"" color=""#c0c0c0"" size=""1"" />"
end function

function get_badwords()
	Dim tmpstr
	tmpstr = ""
	dbRS2.open "select * from " & db_prefix & "badwords",dbConn
	do while not dbRS2.eof
		tmpstr = tmpstr & dbRS2("text") & ", "
		dbRS2.movenext
	loop
	if len(tmpstr)>0 then tmpstr = left(tmpstr,len(tmpstr)-2)
	get_badwords = tmpstr
end function

Sub save_badwords(badstr)
	dbConn.execute "delete from " & db_prefix & "badwords"
	if len(badstr)>0 then
	badsplit = split(badstr,",")
	for i = 0 to ubound(badsplit,1)
		curbad = trim(badsplit(i))
		dbConn.execute "insert into " & db_prefix & "badwords(text,replace_text) values('" & curbad & "','***')"
	next
	end if
End Sub

function FR
	FR = "<span style=""font-size:12px;font-weight:bold;color:#990000"">&nbsp;**FR**</span>"
end function

Sub getUwNews
Dim xmldom, n1,n2
Set xmldom=Server.CreateObject("Microsoft.XMLDOM")
xmldom.SetProperty "ServerHTTPRequest", True
xmldom.async = false
xmldom.load("http://www.unwrittenblog.com/rss.asp")
if xmldom.parseerror = 0 then
	set n1 = xmldom.getElementsByTagName("item")
	Response.Write "<ul>"
	for i = 0 to min(n1.length-1,2)
		set n2 = n1.item(i).childnodes
			Response.Write "<li><a href=""" & n2.item(1).text & """>&raquo;&nbsp;" & n2.item(0).text & "<a /><br>"
			Response.Write "<span class=""small"" style=""color:#fff;"">" & n2.item(5).text & "</span>"
			Response.Write "</li>"
	next
	Response.Write "</ul>"
	else
		response.Write "No news available at the moment"
end if
set n1 = nothing
set n2 = nothing
set xmldom = nothing
End Sub

function getLastestUw
Dim xmldom
Set xmldom=Server.CreateObject("Microsoft.XMLDOM")
xmldom.SetProperty "ServerHTTPRequest", True
xmldom.async = false
xmldom.load("http://www.unwrittenblog.com/latest.asp?r=" & html_decode(request.ServerVariables("HTTP_HOST")))
if xmldom.parseerror = 0 then
	getLastestUw = xmldom.getElementsByTagName("version").item(0).text
	else
		getLastestUw = "<span class=""small"" style=""color:red;"">can't check right now.</span>"
end if
	set xmldom = nothing
end function

function getMessage
Dim xmldom
Set xmldom=Server.CreateObject("Microsoft.XMLDOM")
xmldom.SetProperty "ServerHTTPRequest", True
xmldom.async = false
xmldom.load("http://www.unwrittenblog.com/message.asp")
if xmldom.parseerror = 0 then
  message = xmldom.getElementsByTagName("message").item(0).text
  if len(message) > 0 then
	getMessage = "<div style=""background:red;color:#efefef;font-weight:bold;text-align:center;padding:3px;margin-bottom:5px;font-size:12px;border:1px solid #efefef;"">"
	getMessage = getMessage & message
		getMessage = getMessage & "</div>"
	set nodo = nothing
	set xmldom = nothing
  end if
	else
		getMessage = ""
end if
set xmldom = nothing
end function
%>